package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.App;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Controller
@RequestMapping("/App")

public class AddController {

	@Resource
	private service.AppService AppService;


	@RequestMapping("/index")
	public String appAdd(App app,HttpServletResponse response) {
		try {
			PrintWriter out = response.getWriter();
			int result = AppService.appAdd(app);
			if (result > 0) {
				out.print("<script type=\"text/javascript\">");
				out.print("alert(\"添加成功\");");
				out.print("</script>");
			}else{
				out.print("<script type=\"text/javascript\">");
				out.print("alert(\"添加失败\");");
				out.print("</script>");
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
		return "redirect:/Add/index";

	}

	@RequestMapping("/c")
	public String Login() {

		return "appAdd";
	}

	@RequestMapping("/index")
	public String appAdd() {

		return "index";
	}
	@RequestMapping("/index")
	public String selectAdd(App app ,HttpServletResponse response ) {

		return "index";
	}
	@RequestMapping("/index")
	public String selectAdd() {

		return "index";
	}
}
